package com.hktf.corelib.utils;

/**
 * date: 2021/4/21 15:31.
 *
 * @auther: hexw
 * @function: 数据类型工具类
 */
public class DataHandleUtils {

    /**
     * int 转成bytes
     * @param integer
     * @return
     */
    public static byte[] intToBytes(int integer) {
        int byteNum = (40 - Integer.numberOfLeadingZeros(integer < 0 ? ~integer
                : integer)) / 8;
        byte[] byteArray = new byte[4];
        for (int n = 0; n < byteNum; n++)
            byteArray[3 - n] = (byte) (integer >>> (n * 8));
        return (byteArray);
    }


}
